<include file="../Public/_header.html" />
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2&services=true"></script>
<php>$latlng = explode(',',$partner['location']);</php>
<script>
	var map;
	var ptitle="{$partner['title']}";
	var paddress="{$partner['address']}";
	var pphone="{$partner['phone']}/{$partner['mobile']}";
	var current_marker = null;
	function load_map() {
		map = new BMap.Map("map-box");        // 创建Map实例
		var point = new BMap.Point(116.404, 39.915);    // 创建点坐标
		map.centerAndZoom(point,15);                    // 初始化地图,设置中心点坐标和地图级别。
		//map.centerAndZoom("哈尔滨",12);                   // 初始化地图,设置城市和地图级别。
		map.addControl(new BMap.NavigationControl());               // 添加平移缩放控件
		map.addControl(new BMap.ScaleControl());                    // 添加比例尺控件
		map.addControl(new BMap.OverviewMapControl());              //添加缩略地图控件
		
		map.addEventListener("click", function(e){  
			//if(current_marker!=null){return;}
			map.clearOverlays();
			var point1 = new BMap.Point(e.point.lng, e.point.lat);
			current_marker = new BMap.Marker(point1);  // 创建标注
			map.addOverlay(current_marker);
			//current_marker.enableDragging(true); // 设置标注可拖拽

			$('#location').val(e.point.lat+","+e.point.lng);
		});
		// 将标注添加到地图中

		/**
		var latlng = new google.maps.LatLng(39.925, 116.385);
		var myOptions = {
	  		zoom: 11,
	  		center: latlng,
	  		mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		map = new google.maps.Map(document.getElementById("map-box"), myOptions);
		google.maps.event.addListener(map, 'click', function(event) {
				//alert(event.latLng.lat()+"  "+event.latLng.lng());
				deleteOverlays();
				$('#location').val(event.latLng.lat()+","+event.latLng.lng());
				addBsubMarker(0,event.latLng.lat(),event.latLng.lng(),ptitle,paddress,pphone);
		});
		**/
	}
	
	$(document).ready(function(){
		load_map();
		<php>if(!empty($latlng[0])&&!empty($latlng[1])){</php>
		//addBsubMarker(0,'{$latlng[0]}','{$latlng[1]}',ptitle,paddress,pphone);
		//var latlng = new google.maps.LatLng('{$latlng[0]}','{$latlng[1]}');
  		//map.setCenter(latlng);
  		var point1_ = new BMap.Point( '{$latlng[1]}','{$latlng[0]}' );
		current_marker = new BMap.Marker(point1_);  // 创建标注
		//initMarker(current_marker);
		map.addOverlay(current_marker);
		map.centerAndZoom(point1_,15);  
		<php>}</php>
	});
	
</script>
<div class="so_main">
  <include file="../Admin/Tpl/default/Partner/top_box.html" />
  <style>
  	.form2 dl{
  		float: left;
    	width: 50%;
    }
  </style>
  <div class="form2" id="main_area">
  	<form method="post" action="{:U('/Partner/locationEdit')}" >
  	<input name="partner_id" id='partner_id' type="hidden" value="{$partner['id']}">
  		<div class="clear"></div>
   	<dl class="lineD" style="font-weight:bold;width: 100%;">
      <dt style="padding: 8px 0px 8px 0px;">标记位置：</dt>
      <dd>
      		&nbsp;&nbsp;&nbsp;&nbsp;
      		坐标：<input type="text" name="location" id="location" value="{$partner['location']}">
      		&nbsp;&nbsp;
      		<input type="submit" class="btn_b" value="提交" />
      		&nbsp;&nbsp;&nbsp;&nbsp;
	      	<font style="color:red">{$result}</font>
      </dd>
    </dl>
    
    <div class="clear"></div>
    </form>
    <div id="map-box" style="border: 1px solid #EAEAEA;height: 800px;width: 100%;">
	</div>
  </div>

   
</div>
<include file="../Public/_footer.html" />